<?php
/***
 * 描述：商品查询
 * @category		Mobile		
 * @package			Action			
 * @subpackage		
 * @author			wanght <whtaok@gmail.com>
 * @since			2013-4-6
 * @version			$Id: ProductAction.class.php 97 2013-12-18 03:34:42Z whtaok@gmail.com $
 */
class ProductAction extends MobileAction {
	/**
	 * 描述：商品列表：店铺，分类，名称进行筛选
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function indexAct() {
		$search = array(
				'cate_code'=> I('cate_code'),
				'name'=>I('name'),
				'spread'=>I('spread'),
		);
		switch($search['spread']){
			case 'hot':
				$search['is_hot'] = 1;
				break;
			case 'rmd':
				$search['is_rmd'] = 1;
				break;
			case 'new':
				$search['is_new'] = 1;
				break;
			case 'frn':
				$search['is_foreign'] = 1;
				break;
		}
		switch($search['cate_code']){
			case 'B102':
				$search['cate_code_list'] = array('B102'=>'碳酸饮料','B108'=>'果汁饮料','B107'=>'功能饮料','B103'=>'纯果汁');
				break;
			case 'B108':
				$search['cate_code_list'] = array('B102'=>'碳酸饮料','B108'=>'果汁饮料','B107'=>'功能饮料','B103'=>'纯果汁');
				break;
			case 'B107':
				$search['cate_code_list'] = array('B102'=>'碳酸饮料','B108'=>'果汁饮料','B107'=>'功能饮料','B103'=>'纯果汁');
				break;
			case 'B103':
				$search['cate_code_list'] = array('B102'=>'碳酸饮料','B108'=>'果汁饮料','B107'=>'功能饮料','B103'=>'纯果汁');
				break;
			case 'B105':
				$search['cate_code_list'] = array('B105'=>'啤酒','B106'=>'白酒');
				break;
			case 'B106':
				$search['cate_code_list'] = array('B105'=>'啤酒','B106'=>'白酒');
				break;
			case 'A101':
				$search['cate_code_list'] = array('A101'=>'方便速食','A102'=>'糕点饼干');
				break;
			case 'A102':
				$search['cate_code_list'] = array('A101'=>'方便速食','A102'=>'糕点饼干');
				break;
		}
		$this->assign('search',$search);
		//$this->assign('cateTree',productcate_tree());
		$this->display('index');
	}
	/**
	 * 描述：加载商品列表
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function listAct(){
		$search = array(
				'cate_code'=> I('cate_code'),
				'name'=>I('name'),
				'spread'=>I('spread'),
		);
		switch($search['spread']){
			case 'hot':
				$search['is_hot'] = 1;
				break;
			case 'rmd':
				$search['is_rmd'] = 1;
				break;
			case 'new':
				$search['is_new'] = 1;
				break;
			case 'frn':
				$search['is_frn'] = 1;
				break;
		}
		switch($search['cate_code']){
			case 'B102':
				$search['cate_code_list'] = array('B102'=>'碳酸饮料','B108'=>'果汁饮料','B107'=>'功能饮料','B103'=>'纯果汁');
				break;
			case 'B108':
				$search['cate_code_list'] = array('B102'=>'碳酸饮料','B108'=>'果汁饮料','B107'=>'功能饮料','B103'=>'纯果汁');
				break;
			case 'B107':
				$search['cate_code_list'] = array('B102'=>'碳酸饮料','B108'=>'果汁饮料','B107'=>'功能饮料','B103'=>'纯果汁');
				break;
			case 'B103':
				$search['cate_code_list'] = array('B102'=>'碳酸饮料','B108'=>'果汁饮料','B107'=>'功能饮料','B103'=>'纯果汁');
				break;
			case 'B105':
				$search['cate_code_list'] = array('B105'=>'啤酒','B106'=>'白酒');
				break;
			case 'B106':
				$search['cate_code_list'] = array('B105'=>'啤酒','B106'=>'白酒');
				break;
			case 'A101':
				$search['cate_code_list'] = array('A101'=>'方便速食','A102'=>'糕点饼干');
				break;
			case 'A102':
				$search['cate_code_list'] = array('A101'=>'方便速食','A102'=>'糕点饼干');
				break;
		}
		$order='ordlist';
		$mod = new ProductPriceViewModel();
		list($list,$page) = $mod->findListPage($this->curr_shop_id,$search,$order);
		
		foreach ($list as $key => $value){
			$list[$key]['pic']=m_prod_pic($value['prod_id']);
			$list[$key]['spec']=m_prod_spec($value['spec'],$value['spec_qty'],$value['spec_unit']);
		}
		$this->ajaxReturn(array('list'=>$list,'page'=>$page));
	}


}

?>